import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import cesium from 'vite-plugin-cesium'
import { resolve } from 'path';
function pathResolve(dir) {
  return resolve(process.cwd(), '.', dir);
}
export default defineConfig({
  plugins: [vue(),cesium()],
  base: './', 
  resolve: {
    alias: [
        {
          find: /\/@\//,
          replacement: pathResolve('src') + '/',
        },
        {
          find: /@\//,
          replacement: pathResolve('src') + '/',
        },
    ]
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
        modifyVars: {
          'primary-color': '#1890ff'
        }
      }
    }
  },
  optimizeDeps: {
    exclude: [
      'cesium/Workers/transferTypedArrayTest',
      'cesium/Workers/shaders/postProcessStages'
    ]
  },
  server: {
    host: true, // 启用局域网IP访问
    port: 8081, // 端口号
    proxy: {
      '/Portal': {
        target: 'http://172.20.1.60:13305',
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/geoserver/, '')
      },
      '/tiles_ty': {
        target: 'http://172.20.1.60:13305/',
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/geoserver/, '')
      }
    },
    fs: {
      strict: false,
      allow: ['..']
    }
  },
  publicDir: 'public',
  build: {
    outDir: 'map-ty',
    terserOptions: {
      compress: {
        drop_console: true, // 生产环境去除console
        drop_debugger: true, // 生产环境去除debugger
      },
    }
  }
})
